#pragma once
#include "ILayer.h"
#include "IContainerType.h"
#include "boost/shared_ptr.hpp"
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>

class CPhysicalLayer : public ILayer, public IContainerType<std::vector<boost::shared_ptr<IProtocol> >, boost::shared_ptr<IProtocol> >
{
public:
	CPhysicalLayer(void);
	virtual ~CPhysicalLayer(void);
	friend class boost::serialization::access;
	template<class Archive> 
	void serialize(Archive & ar, const unsigned int version) 
	{
		ar & boost::serialization::base_object<ILayer>(*this);
		ar & boost::serialization::base_object<IContainerType<std::vector<boost::shared_ptr<IProtocol> >, boost::shared_ptr<IProtocol> > >(*this);
	}

	virtual void addProtocol( const boost::shared_ptr<IProtocol>& protocol );

	virtual const boost::shared_ptr<IProtocol>& getProtocol( const std::string& name ) const;

	virtual void removeProtocol( const std::string& name );

	virtual StackUtils::e_Status Decode( CPacket& packet );

	virtual StackUtils::e_Status Encode( CPacket& packet );

	virtual void init();

private:

	virtual void add( const boost::shared_ptr<IProtocol>& element );

};
